package com.haimi.shiguang.business.splash;

import android.content.Intent;
import android.view.View;

import com.haimi.shiguang.R;
import com.haimi.shiguang.base.BaseActivity;
import com.haimi.shiguang.business.user.login.LoginActivity;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * @author changsunhaipeng
 */
public class SplashActivity extends BaseActivity {


    @Override
    public int setLayout() {
        return R.layout.activity_splash;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initListener() {

    }

    @Override
    public void initData() {
        Observable.timer(3, TimeUnit.SECONDS)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        Intent intent = new Intent(getContextWithinHost(), LoginActivity.class);
                        startActivity(intent);
                        finishCurrent();
                    }
                });
    }

    @Override
    public void onClick(View v) {

    }
}
